package com.shen.staservice.schedule;

import com.shen.staservice.service.StatisticsDailyService;
import com.shen.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduledTask {


    @Autowired
    StatisticsDailyService service;
    @Scheduled(cron = "0 0 1 * * ? ")
    public void task2(){
        //把前一天的数据进行--添加

        service.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }

    //每隔五秒钟执行这个方法
    //@Scheduled(cron = "0/5 * * * * ?")
    public  void task1(){
        System.out.println("task 1---执行了"+new Date().getTime());
    }

    //0 0 1 * * ?  --凌晨一点执行
}
